package org.websocket.encoder;

import com.alibaba.fastjson.JSON;
import org.websocket.dto.WebSocketBuffer;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public class WebSocketEncoder implements Encoder.Text<WebSocketBuffer> {

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }

    @Override
    public String encode(WebSocketBuffer buffer) throws EncodeException {
        return JSON.toJSONString(buffer);
    }
}
